package cn.tk.spring;

import cn.tk.service.log.customer.OutcallCollectCustomer;
import cn.tk.service.log.queue.OutcallCollectQueue;
import cn.tk.service.mr.OutcallCollectService;
import cn.tk.utils.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created by denglw on 2019/7/31.<br/>
 * Desc: 系统启动后，开启异步接口访问日志数据入库的线程
 */
@Component
@Order(10)
@Slf4j
public class AccessLogRunner implements CommandLineRunner {

    @Override
    public void run(String... args) {
        ThreadPoolExecutor pool = ThreadUtil.pool();
        OutcallCollectService outcallCollectService = BeanCreater.getBean(OutcallCollectService.class);
        // 外呼信息采集
        pool.execute(new OutcallCollectCustomer(OutcallCollectQueue.getInstance(), outcallCollectService));
        log.info("成功启动外呼信息采集线程.");
    }
}
